/*
 * Copyright (C) 2009 Yury Kudryashov.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package name.kudryashov.collections;

/**
 * Helper companion class to create tuples.
 */
public final class Tuple {

    private Tuple() {}

    /**
     * Creates a new {@link Tuple2} from the given arguments
     * @param t1 first arg of the tuple
     * @param t2 second arg of the tuple
     * @param <T1> type of the first arg
     * @param <T2> type of the second arg
     * @return the new tuple
     */
    public static <T1, T2> Tuple2<T1, T2> tuple(T1 t1, T2 t2) {
        return new Tuple2<T1,T2>(t1, t2);
    }

    /**
     * Same as {@link #tuple(Object, Object)} but with a different name for more convenience sometimes.
     */
    public static <T1, T2> Tuple2<T1, T2> pair(T1 t1, T2 t2) {
        return tuple(t1, t2);
    }

    /**
     * Creates a new {@link Tuple3} from the given arguments
     * @param t1 first arg of the tuple
     * @param t2 second arg of the tuple
     * @param t3 third arg of the tuple
     * @param <T1> type of the first arg
     * @param <T2> type of the second arg
     * @param <T3> type of the third arg
     * @return the new tuple
     */
    public static <T1, T2, T3> Tuple3<T1, T2, T3> tuple(T1 t1, T2 t2, T3 t3) {
        return new Tuple3<T1,T2,T3>(t1, t2, t3);
    }
}
